#region imports

using System;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Collections.Generic;
using MimeCloud.AssetManagement.Business.Interface;

#endregion

namespace MimeCloud.AssetManagement.Business
{
    [Serializable]
    public class AssetRightsUsage : IAssetRightsUsage 
    {
        #region properties

        [XmlElement ( "id" )]
        public int ID { get; set; }

        [XmlIgnore]
        public int StatusID { get; set; }

        [XmlElement ( "startpublishdate" )]
        public DateTime StartPublishDate { get; set; }

        [XmlElement ( "endpublishdate" )]
        public DateTime EndPublishDate { get; set; }

        [XmlElement ( "group" )]
        public string Group { get; set; }

        [XmlIgnore]
        public int AssetID { get; set; }

        [XmlElement ( "Asset" )]
        public IAsset Asset { get; set; }

        [XmlElement ( "Status" )]
        public IStatus Status { get; set; }

        #endregion

        #region constructors

        public AssetRightsUsage ( ) { }

        public AssetRightsUsage ( int id , int statusId , DateTime start , DateTime end , string group , int assetId )
        {
            this.ID = id;
            this.StatusID = statusId;
            this.StartPublishDate = start;
            this.EndPublishDate = end;
            this.Group = group;
            this.AssetID = assetId;
        }

        public AssetRightsUsage ( IAssetRightsUsage entity )
        {
            this.ID = entity.ID;
            this.StatusID = entity.StatusID;
            this.StartPublishDate = entity.StartPublishDate;
            this.EndPublishDate = entity.EndPublishDate;
            this.Group = entity.Group;
            this.AssetID = entity.AssetID;
        }

        #endregion

        #region overridden methods

        public override string ToString ( )
        {
            StringBuilder str = new StringBuilder ( );

            str.Append ( "-> ID: " + this.ID.ToString ( ) );
            str.Append ( "-> StatusID: " + this.StatusID.ToString ( ) );
            if ( this.StartPublishDate !=  null ) str.Append ( "-> StartDate: " + this.StartPublishDate.ToShortDateString( ) );
            if ( this.EndPublishDate != null ) str.Append ( "-> EndDate: " + this.EndPublishDate.ToShortDateString() );
            str.Append ( "-> Group: " + this.Group );
            str.Append ( "-> AssetID: " + this.AssetID.ToString ( ) );

            return str.ToString ( );
        }

        #endregion
    }
}
